package com.zl.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.system.comm.util.CheckUtil;
import com.system.comm.util.JsonUtils;
import com.system.common.pojo.BisBeautyRecord;
import com.system.common.pojo.BisCustomUser;
import com.zl.service.ZlBisHomeService;
import com.zl.service.ZlBisShopService;

@Controller
@RequestMapping("home")
public class wechatHomeController {
	@Autowired 
	private ZlBisShopService zlBisShopService;

	@Autowired
	private ZlBisHomeService zlBisHomeService;
	
	@RequestMapping("goHome")
	public String goHome(){
		return "/wechat/my/home";
	}
	
	@RequestMapping(value = "goFeedback")
	public  String goFeedback(HttpServletRequest request, HttpServletResponse response,HttpSession session){
	
		return "wechat/my/feedback";
	}
	
	@RequestMapping(value = "saveOpinion")
	public  void saveOpinion(HttpServletRequest request, HttpServletResponse response,HttpSession session){
	      BisCustomUser bisCustomUser=CheckUtil.getUserSession(session);
	      Map<String, Object> map=zlBisHomeService.saveOpinion(bisCustomUser.getCustomUserId(), request);
	      String str=JsonUtils.toJson(map);
		  CheckUtil.responseW(response, str);
	}
	
	@RequestMapping("goMyBeauty")
	public String goMyBeauty(HttpSession session,Model model){
		BisCustomUser customUserPO=CheckUtil.getUserSession(session);
		
		System.out.println(customUserPO.getCustomUserId());
		model.addAttribute("customUserPO", customUserPO);
		
		return "wechat/my/myBeauty";
	}
	
	
	
	
	@RequestMapping("goExchangeBeauty")
	public String goExchangeBeauty(HttpSession session,Model model){
		
		
		return "wechat/my/exchangeBeauty";
	}
	
	
	@RequestMapping("initBeautyRecord")
	public String initBeautyRecord(){
		return "wechat/my/beautyRecordList";
	}
	
	@RequestMapping("searchBeautyRecord")
	public String searchBeautyRecord(HttpSession session,Model model,HttpServletResponse response){
		List<BisBeautyRecord> bisBeautyRecords=zlBisShopService.queryBeautyRecord();
		String str=JsonUtils.toJson(bisBeautyRecords);
		CheckUtil.responseW(response, str);
		return "wechat/my/beautyRecordList";
	}
	
	

}
